<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	request.setAttribute("basePath", basePath);
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="<%=basePath%>css/easyui.css">
<link rel="stylesheet" type="text/css" href="<%=basePath%>css/icon.css">
<link rel="stylesheet" type="text/css" href="<%=basePath%>css/demo.css">
<script type="text/javascript" src="<%=basePath%>js/jquery.min.js"></script>
<script type="text/javascript" src="<%=basePath%>js/jquery.easyui.min.js"></script>
<script type="text/javascript">
	$(document).ready(function(){
		$('#sendWorkEmail').click(function(){
			var rowServers = getSelectedServers();
		  	if(rowServers.length==0 || rowServers.length==0){
			  	return;
		  	}
		  	var requestParams="{\"servers\":";
			  requestParams += "["
			  $.each(rowServers, function(index, value){
				  requestParams += "{\"tag\"" + ":\"" + value['serverId'] + '_' + value['serverName'] + "\"},";			                     
			  });
			  requestParams = requestParams.substring(0, requestParams.length - 1);
			  requestParams += "]";
			  
			  requestParams += ",";
			  requestParams += "\"emailTitle\":" + "\"" + $('#emailTitle').val() + "\",";
			  requestParams += "\"emailContent\":" + "\"" + $('#emailContent').val() + "\",";
			  requestParams += "\"goodsType0\":" + "\"" + $('#goodsType0').val() + "\",";
			  requestParams += "\"goodsId0\":" + "\"" + $('#goodsId0').val() + "\",";
			  requestParams += "\"goodsAmount0\":" + "\"" + $('#goodsAmount0').val() + "\",";
			  requestParams += "\"goodsType1\":" + "\"" + $('#goodsType1').val() + "\",";
			  requestParams += "\"goodsId1\":" + "\"" + $('#goodsId1').val() + "\",";
			  requestParams += "\"goodsAmount1\":" + "\"" + $('#goodsAmount1').val() + "\",";
			  requestParams += "\"goodsType2\":" + "\"" + $('#goodsType2').val() + "\",";
			  requestParams += "\"goodsId2\":" + "\"" + $('#goodsId2').val() + "\",";
			  requestParams += "\"goodsAmount2\":" + "\"" + $('#goodsAmount2').val() + "\",";
			  requestParams += "\"goodsType3\":" + "\"" + $('#goodsType3').val() + "\",";
			  requestParams += "\"goodsId3\":" + "\"" + $('#goodsId3').val() + "\",";
			  requestParams += "\"goodsAmount3\":" + "\"" + $('#goodsAmount3').val() + "\",";
			  requestParams += "\"goodsType4\":" + "\"" + $('#goodsType4').val() + "\",";
			  requestParams += "\"goodsId4\":" + "\"" + $('#goodsId4').val() + "\",";
			  requestParams += "\"goodsAmount4\":" + "\"" + $('#goodsAmount4').val() + "\"";
			  requestParams += "}";
			  var url = "SendWorkEmailServlet?paras=" + requestParams; 
			  $.post(url, function(data){
				  $('#w').window('open');
				  $('#w').html(data);
			  });
		});
	});
	
	function submitForm() {
		$('#ff').submit();
	}
</script>
<title>全服发送邮件</title>
</head>
<body class="easyui-layout">
	<div data-options="region:'north',border:false"
		style="height: 60px; background: #B3DFDA; padding: 10px"></div>
	<div data-options="region:'west',split:true,title:' '"
		style="width: 20%; padding: 10px;">
		<ul type="none">
			<c:forEach var="gmComm" items="${gmComms}">
					<li><a href="ToGMFunctionServlet?tag=${gmComm.tag}" class="easyui-linkbutton">${gmComm.gmName}</a></li>
			</c:forEach>
		</ul>
	</div>
	<!-- <div data-options="region:'east',split:true,collapsed:false,title:' '" style="width: 50%; padding: 10px;">
		<textarea style="font-size:12px; color:#0f0;background-color:black;widht:100%;height:100%"; cols="220"; rows="50" id="console" readonly="readonly"></textarea>
	</div> -->
	<div data-options="region:'center',title:' '" style="width: 80%">
		<jsp:include page="gmServers.jsp" />
		<!-- <form id="chooseGMServer" action="#" method="post" entyctype="text/plain">
				<table id="t1" title="选择需要更新的服务器" style="width:100%;height:300px" data-options="rownumbers:true,singleSelect:true,autoRowHeight:true,pagination:true,pageSize:10,
																											url:'GetGMServersServlet',method:'get',singleSelect:true">
					<thead>
					<tr>
						<th data-options="field:'ck',checkbox:true"></th>
						<th data-options="field:'serverId',width:50">id</th>
						<th data-options="field:'serverName',width:80">服务器名</th>
					</tr>
					</thead>
				</table>
		</form>	 -->
		<div class="easyui-panel" title="" style="width: 100%">
		<div style="padding: 10px 60px 20px 60px">
			<form id="ff" method="post" action="SendEmailServlet">
				<table cellpadding="5">
					<tr>
						<td>邮件标题:</td>
						<td><input class="easyui-textbox" type="text"
							id="emailTitle" data-options="required:true"
							value="${queryEmailInfo.playerName}"></input></td>
					</tr>
					<tr>
						<td>邮件内容:</td>
						<td><input class="easyui-textbox" type="text"
							id="emailContent" data-options="required:true"
							value="${queryEmailInfo.playerName}"></input></td>
					</tr>
					<tr>
						<td>物品类型</td>
						<td>
							<select  id="goodsType0">
									<c:forEach var="type" items="${goodsType}">
										 	<option value="${type.value}">${type.name}</option>
									</c:forEach>
							</select>
						</td>
						<td>物品id</td>
						<td><input class="easyui-textbox" type="text"
							id="goodsId0" data-options="required:true"
							value="${queryEmailInfo.playerName}"></input></td>
						<td>物品数量</td>
						<td><input class="easyui-textbox" type="text"
							id="goodsAmount0" data-options="required:true"
							value="${queryEmailInfo.playerName}"></input></td>
					</tr>
					<tr>
						<td>物品类型</td>
						<td>
							<select id="goodsType1">
									<c:forEach var="type" items="${goodsType}">
										 	<option value="${type.value}">${type.name}</option>
									</c:forEach>
							</select>
						</td>
						<td>物品id</td>
						<td><input class="easyui-textbox" type="text"
							id="goodsId1" data-options="required:true"
							value="${queryEmailInfo.playerName}"></input></td>
						<td>物品数量</td>
						<td><input class="easyui-textbox" type="text"
							id="goodsAmount1" data-options="required:true"
							value="${queryEmailInfo.playerName}"></input></td>
					</tr>
					<tr>
						<td>物品类型</td>
						<td>
							<select id="goodsType2">
									<c:forEach var="type" items="${goodsType}">
										 	<option value="${type.value}">${type.name}</option>
									</c:forEach>
							</select>
						</td>
						<td>物品id</td>
						<td><input class="easyui-textbox" type="text"
							id="goodsId2" data-options="required:true"
							value="${queryEmailInfo.playerName}"></input></td>
						<td>物品数量</td>
						<td><input class="easyui-textbox" type="text"
							id="goodsAmount2" data-options="required:true"
							value="${queryEmailInfo.playerName}"></input></td>
					</tr>
					<tr>
						<td>物品类型</td>
						<td>
							<select id="goodsType3">
									<c:forEach var="type" items="${goodsType}">
										 	<option value="${type.value}">${type.name}</option>
									</c:forEach>
							</select>
						</td>
						<td>物品id</td>
						<td><input class="easyui-textbox" type="text"
							id="goodsId3" data-options="required:true"
							value="${queryEmailInfo.playerName}"></input></td>
						<td>物品数量</td>
						<td><input class="easyui-textbox" type="text"
							id="goodsAmount3" data-options="required:true"
							value="${queryEmailInfo.playerName}"></input></td>
					</tr>
					<tr>
						<td>物品类型</td>
						<td>
							<select id="goodsType4">
									<c:forEach var="type" items="${goodsType}">
										 	<option value="${type.value}">${type.name}</option>
									</c:forEach>
							</select>
						</td>
						<td>物品id</td>
						<td><input class="easyui-textbox" type="text"
							id="goodsId4" data-options="required:true"
							value="${queryEmailInfo.playerName}"></input></td>
						<td>物品数量</td>
						<td><input class="easyui-textbox" type="text"
							id="goodsAmount4" data-options="required:true"
							value="${queryEmailInfo.playerName}"></input></td>
					</tr>
					<!-- <tr>
						<td>全服发送</td>
						<td><input type="checkbox" id="isWholeServer" /></td>
					</tr> -->
				</table>
			</form>
			<div style="text-align: center; padding: 5px">
				<a href="#" class="easyui-linkbutton"
					id="sendWorkEmail">发送全服邮件</a> <a href="javascript:void(0)"
					class="easyui-linkbutton" onclick="clearForm()">Clear</a>
			</div>
		</div>
	</div>
	</div>
	<div id="w" class="easyui-window" title="Basic Window" data-options="iconCls:'icon-save'" style="width:500px;height:200px;padding:10px;" maximized="true" collapsible="false" minimizable="false">
		The window content.
	</div>
	
</body>
</html>